package com.mm.cme.kotlin_001.level03_object_oriented_program

import com.mm.cme.kotlin_001.utils.pl

/**
 * Descriptions：
 * <p>
 * Author：ChenME
 * Date：2017/7/17
 * Email：ibelieve1210@163.com
 */
abstract class Person(open val age: Int) {
    abstract fun work()
}

class MaNong(age: Int) : Person(age) {

    override val age: Int
        get() = 0

    override fun work() {
        pl("我是码农，我在写代码！")
    }
}

class Doctor(age: Int) : Person(age) {
    override fun work() {
        pl("我是医生，我在给病人看病！")
    }
}

fun main(args: Array<String>) {
    val person: Person = MaNong(23)
    person.work()
    pl(person.age)

    val person2: Person = Doctor(40)
    person2.work()
    pl(person2.age)
}